using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Drawing;

namespace mtdsharp
{
    public class Utilities
    {
        public static Image GenerateEmblem(int width, int height, string text, Color bgColor, Color fgColor)
        {
            Image emblem = new Bitmap(width, height);
            Graphics canvas = Graphics.FromImage(emblem);
            Brush textbrush = new SolidBrush(fgColor);

            StringFormat format = new StringFormat();
            format.Alignment = StringAlignment.Center;
            format.LineAlignment = StringAlignment.Center;

            canvas.Clear(bgColor);
            canvas.DrawString(text, new Font("Segoe UI", (int)(height * 0.35)), textbrush, width / 2, height / 2, format);
            canvas.Save();

            return emblem;
        }

        public static String Format(String line)
        {
            String result = "";
            char[] newLine = line.ToLower().ToCharArray();
            newLine[0] = Char.ToUpper(newLine[0]);
            result += newLine[0];
            for (int x = 1; x < newLine.Length; x++)
            {
                char c = newLine[x];
                if (newLine[x] == ' ')
                {
                    c = newLine[x + 1];
                    c = Char.ToUpper(c);
                    result += ' ';
                    x++;
                }
                result += c;
            }
            return result;
        }


    }
}
